package com.hospital.pharmacy.impl;

import com.alibaba.fastjson.JSON;
import com.hospital.pharmacy.dao.MedicineTypeMapper;
import com.hospital.pharmacy.entity.MedicineType;
import com.hospital.pharmacy.service.MedicineTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: Hospital
 * @description: 药品类型
 * @author: 杨曼珍
 * @create: 2019-01-04 18:34
 **/
@Service
public class MedicineTypeServiceImpl implements MedicineTypeService {
    @Autowired
    MedicineTypeMapper medicineTypeMapper;

    @Override
    public String getAllMedicineType(){
        List<MedicineType>medicineTypes=medicineTypeMapper.selectAllMedType();
        List<Map<String,String>>resaultmap=new ArrayList<>();
        Map<String,String>map;
        for (MedicineType medicineType:medicineTypes){
            map=new HashMap<>();
            map.put("mdc_type_id",medicineType.getId().toString());
            map.put("mdc_type_name",medicineType.getMdcTypeName());
            resaultmap.add(map);
        }
        return JSON.toJSONString(resaultmap);
    }

}
